<!-- 添加员工 -->
<template>
	<div>
		<text class="form-title">员工信息</text>
		<empForm :formInline="formInline" :formItem="formItem" @changePicker="changePicker" @getFiles="getFiles"></empForm>
	</div>
</template>

<script>
	import empForm from "../../components/current/vForm.vue";

	export default {
		components: {
			empForm
		},
		data() {
			return {
				//表格参数
				formItem: [{
				type: 'uploadFile',
				fileType: 'faces',
				label: "头像",
				clumn: 'faces'
				},  {
					type: 'input',
					label: "员工姓名",
					placeholder: "请输入员工姓名",
					focus: true,
					clumn: 'empName'
				}, {
					type: 'input',
					label: "身份证号",
					inputType:'idcard',
					placeholder: "请输入身份证号",
					clumn: 'idNum'
				}, {
					type: 'input',
					label: "手机号码",
					inputType:'number',
					placeholder: "请输入手机号码",
					clumn: 'phone'
				}, {
					type: 'radio',
					label: "员工性别",
					options: [{
						index: '1',
						value: '1',
						text: '男',
						checked: 'checked'
					}, {
						index: '2',
						value: '2',
						text: '女',
					}],
					clumn: 'sex'
				}, {
					type: 'radio',
					label: "是否贫困户",
					options: [{
						index: '1',
						value: '1',
						text: '否',
						checked: 'checked'
					}, {
						index: '2',
						value: '2',
						text: '是',
					}],
					clumn: 'isPoorMan'
				}, {
					type: 'radio',
					label: "员工类型",
					options: [{
						index: '1',
						value: '1',
						text: '合同工',
						checked: 'checked'
					}, {
						index: '2',
						value: '2',
						text: '临时工',
					}],
					clumn: 'empType'
				}, {
					type: 'picker',
					pickerType: '',
					label: "学历类别",
					placeholder: "请选择学历类别",
					array: ['第一个', '第二个', '第三个'],
					index: "",
					clumn: 'qualifications'
				}, {
					type: 'picker',
					pickerType: '',
					label: "角色类型",
					placeholder: "请选择角色类型",
					array: ['角色第一个', '第二个', '第三个'],
					index: "",
					clumn: 'role'
				}, {
					type: 'radio',
					label: "计工类型",
					options: [{
						index: '1',
						value: '1',
						text: '月',
						checked: 'checked'
					}, {
						index: '2',
						value: '2',
						text: '天',
					}, {
						index: '3',
						value: '3',
						text: '时',
					}],
					clumn: 'timeType'
				}, {
					type: 'textarea',
					placeholder: "请输入详细内容",
					clumn: 'detailInfo'
				}],
				//表单字段数据
				formInline: {
					faces: ["/static/images/icons/icon_yuangong.svg"],
					empName: "",
					idNum: "",
					phone: "",
					sex: "",
					isPoorMan: "",
					empType: "",
					qualifications: "",
					role: "",
					timeType: "",
					detailInfo: "",
				},
			}
		},

		methods: {
			// 选择器发生改变时
			changePicker(i, clumn, value) {
				// 普通选择器赋值
				if (this.formItem[i].pickerType == '' || this.formItem[i].pickerType == 'selector') {
					this.formInline[clumn] = this.formItem[i].array[value];
					return
				}
				//时间选择器赋值
				if (this.formItem[i].pickerType == 'date') {
					this.formInline[clumn] = value;
					console.log("-------" + this.formInline[clumn])
					return
				}
			},

			// 接收上传图片路径并赋值
			getFiles(i, clumn, value) {
				this.formInline[clumn] = value;
			}
		}
	}
</script>

<style>
	.form-title {
		padding: 0 5%;
		color: rgb(136, 136, 136);
		line-height: 60rpx;
	}
</style>
